package com.factors.ZhangDingHou.Distance_from_Home;

import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Reducer;

import java.io.IOException;

public class DistanceFromHomeCountReducer extends Reducer<Text, DistanceFromHomeCount, Text, Text> {

    @Override
    protected void reduce(Text key, Iterable<DistanceFromHomeCount> values, Context context) throws IOException, InterruptedException {
        int totalCount = 0;

        for (DistanceFromHomeCount val : values) {
            totalCount += val.getCount();
        }


        context.write(key, new Text("Count: " + totalCount));
    }
}